<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: MapLayer.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: MapLayer.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/*
 * @Description: In User Settings Edit
 * @Author: fjl
 * @Date: 2019-09-06 16:27:38
 * @LastEditTime: 2019-09-19 15:36:08
 * @LastEditors: mayuanye
 */
/**
 * @content android视图点对象功能组件
 * @author fjl 2019-6-24 下午2:52:36
 */
import { NativeModules } from 'react-native';
let ML = NativeModules.JSMapLayer;
let XClsType = NativeModules.JSXClsType;
import Rect from './Rect.js';
import SRefData from './SRefData.js';
import SimpleLabel from './SimpleLabel.js';
import Themes from './Themes.js';
import SFeatureCls from './SFeatureCls.js';
import AnnotationCls from './AnnotationCls.js';

/**
 * @class MapLayer
 */
export default class MapLayer {
  /**
   * 构造一个新的 MapLayer 对象。
   * @memberOf MapLayer
   * @returns {Promise.&lt;MapLayer>}
   */
  async createObj() {
    try {
      var { MapLayerId } = await ML.createObj();
      var mapLayer = new MapLayer();
      mapLayer._MGMapLayerId = MapLayerId;
      return mapLayer;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取图层名称
   * @memberOf MapLayer
   * @returns {Promise&lt;*>}
   */
  async getName() {
    try {
      let name = await ML.getName(this._MGMapLayerId);
      return name;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取图层名称
   * @memberOf MapLayer
   * @param {String} Name 图层名称
   * @returns {Promise&lt;*>}
   */
  async setName(Name) {
    try {
      await ML.setName(this._MGMapLayerId, Name);
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取图层的URL
   * @memberOf MapLayer
   * @returns {Promise&lt;*>}
   */
  async getURL() {
    try {
      let url = await ML.getURL(this._MGMapLayerId);
      return url;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 设置图层URL地址
   * @memberOf MapLayer
   * @param {String} URL 图层URL地址
   * @returns {Promise&lt;void>}
   */
  async setURL(URL) {
    try {
      await ML.setURL(this._MGMapLayerId, URL);
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取图层状态
   * @memberOf MapLayer
   * @returns {Promise&lt;*|NavigationPreloadState>}
   */
  async getState() {
    try {
      let state = await ML.getState(this._MGMapLayerId);
      return state;
    } catch (e) {
      console.error(e);
    }
  }
  /**
   * 设置图层状态
   *@memberOf MapLayer
   * @param {Boolean} State 图层状态
   */
  async setState(State) {
    try {
      await ML.setState(this._MGMapLayerId, State);
    } catch (e) {
      console.error(e);
    }
  }
  /**
   * 设置图层是否显示
   * @memberOf MapLayer
   * @param {Boolean} visible 图层是否显示
   */
  async setVisible(visible) {
    try {
      await ML.setVisible(this._MGMapLayerId, visible);
    } catch (e) {
      console.error(e);
    }
  }
  /**
   * 获取图层是否显示
   * @memberOf MapLayer
   */
  async getIsVisible() {
    try {
      let state = await ML.getIsVisible(this._MGMapLayerId);
      return state;
    } catch (e) {
      console.error(e);
    }
  }
  /**
   * 获取图层最小显示比率
   * @memberOf MapLayer
   *
   */
  async getMinScale() {
    try {
      let minScale = await ML.getMinScale(this._MGMapLayerId);
      return minScale;
    } catch (e) {
      console.error(e);
    }
  }
  /**
   * 设置图层最小显示比率
   * @memberOf MapLayer
   * @param MinScale 图层最小显示比率
   */
  async setMinScale(MinScale) {
    try {
      await ML.setMinScale(this._MGMapLayerId, MinScale);
    } catch (e) {
      console.error(e);
    }
  }
  /**
   * 获取图层最大显示比率
   * @memberOf MapLayer
   */
  async getMaxScale() {
    try {
      let maxScale = await ML.getMaxScale(this._MGMapLayerId);
      return maxScale;
    } catch (e) {
      console.error(e);
    }
  }
  /**
   * 设置图层最大显示比率
   *@memberOf MapLayer
   * @param MaxScale 图层最大显示比率
   */
  async setMaxScale(MaxScale) {
    try {
      await ML.setMaxScale(this._MGMapLayerId, MaxScale);
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取图层的权重
   * @memberOf MapLayer
   * @returns {Promise&lt;*>}
   */
  async getWeight() {
    try {
      let weight = await ML.getWeight(this._MGMapLayerId);
      return weight;
    } catch (e) {
      console.error(e);
    }
  }
  /**
   * 设置图层的权重
   * @memberOf MapLayer
   * @param {String} Weight 权重
   */
  async setWeight(Weight) {
    try {
      await ML.setWeight(this._MGMapLayerId, Weight);
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 查看图层是否有效
   * @memberOf MapLayer
   * @returns {Promise&lt;*>}
   */
  async getIsValid() {
    try {
      let IsValid = await ML.getIsValid(this._MGMapLayerId);
      return IsValid;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取地图范围
   * @memberOf MapLayer
   * @returns {Promise&lt;Rect>}
   */
  async getRange() {
    try {
      var { rectId } = await ML.getViewRange(this._MGMapLayerId);
      var rect = null;
      if (rectId != null) {
        rect = new Rect();
        rect._MGRectId = rectId;
      }
      return rect;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取空间参照系
   * @memberof MapLayer
   * @returns {Promise&lt;SRefData>}
   */
  async getSrefInfo() {
    try {
      var { SRefDataId } = await ML.getSrefInfo(this._MGMapLayerId);
      var sRefInfo = null;
      if (SRefDataId != null) {
        sRefInfo = new SRefData();
        sRefInfo._MGSRefDataId = SRefDataId;
      }

      return sRefInfo;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取类类型
   * @memberof MapLayer
   * @returns {Number} 类类型（int类型的数值；例如 30 -- XClsType.SFCls）
   */
  async getClsType() {
    try {
      let clsType = await ML.getClsType(this._MGMapLayerId);
      return clsType;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取要素几何类型
   * @memberof MapLayer
   * @returns {Number} 要素几何类型（int类型的数值；例如 1--GeomType.GeomPnt
   */
  async GetGeometryType() {
    try {
      let geometryType = await ML.GetGeometryType(this._MGMapLayerId);
      return geometryType;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取当前的标注
   * @memberof MapLayer
   * @returns {Promise&lt;Label>}} 成功返回当前的标注
   */
  async getLabel() {
    try {
      var { LabelId, LabelType } = await ML.getLabel(this._MGMapLayerId);
      let label = null;
      if (LabelId != null) {
        switch (LabelType) {
          case 0x0100:
            label = new SimpleLabel();
            label._MGLabelId = LabelId;
            break;
        }
      }

      return label;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获获取专题图列表
   * @memberof MapLayer
   * @returns {Promise&lt;Themes>}} 成功返回专题图列表
   */
  async getThemes() {
    try {
      var { ThemesId } = await ML.getThemes(this._MGMapLayerId);
      var themes = null;
      if (ThemesId != null) {
        themes = new Themes();
        themes._MGThemesId = ThemesId;
      }

      return themes;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 复制图层
   * @memberof MapLayer
   * @returns {Promise&lt;MapLayer>}} 成功返回克隆之后的图层
   */
  async clone() {
    try {
      var { MapLayerId } = await ML.clone(this._MGMapLayerId);
      var mapLayer = null;
      if (MapLayerId != null) {
        mapLayer = new MapLayer();
        mapLayer._MGMapLayerId = MapLayerId;
      }

      return mapLayer;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 附加外部数据
   * @memberof MapLayer
   * @param {Object} cls 地理类对象
   * @return {boolean} true/false 成功/失败
   */
  async attachData(cls) {
    try {
      let result = await ML.attachData(this._MGMapLayerId, cls._MGBasClsId);
      return result;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 附加解除
   * @memberof MapLayer
   * @return {boolean} true/false 成功/失败
   */
  async detachData() {
    try {
      let result = await ML.detachData(this._MGMapLayerId);
      return result;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取图层要素数据类
   * @memberof MapLayer
   * @return {Promise&lt;IBasCls>} 成功获得数据类
   */
  async getData() {
    try {
      let xClsType = await ML.getClsType(this._MGMapLayerId);
      let { IBasClsId } = await ML.getData(this._MGMapLayerId);
      let xCls = null;
      if (IBasClsId != null) {
        switch (xClsType) {
          case XClsType.SFCls: // 30-简单要素类
            xCls = new SFeatureCls();
            xCls._MGVectorClsId = IBasClsId;
            break;
          case XClsType.ACls: // 5-注记类
            xCls = new AnnotationCls();
            xCls._MGVectorClsId = IBasClsId;
            break;
        }
      }

      return xCls;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 存为XML
   * @memberof MapLayer
   * @param {boolean} onlyStyle true:仅导出样式  false:除图层样式信息外还包括图层的name、geometryType、url、layerWeight、state信息
   * @return {String} xml
   */
  async toXML(onlyStyle) {
    try {
      let xml = await ML.toXML(this._MGMapLayerId, onlyStyle);
      return xml;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 从XML导入
   * @memberof MapLayer
   * @param strXML
   * @param onlyStyle true:仅导入样式信息  false:除图层样式信息外还包括图层的name、geometryType、url、layerWeight、state信息
   * @return {int} 1-成功；0-失败
   */
  async fromXML(strXMl, onlyStyle) {
    try {
      let result = await ML.fromXML(this._MGMapLayerId, strXMl, onlyStyle);
      return result;
    } catch (e) {
      console.error(e);
    }
  }
}
</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnnClsInfo.html">AnnClsInfo</a></li><li><a href="AnnInfo.html">AnnInfo</a></li><li><a href="Annotation.html">Annotation</a></li><li><a href="AnnotationCls.html">AnnotationCls</a></li><li><a href="AnnotationsOverlay.html">AnnotationsOverlay</a></li><li><a href="AnnotationView.html">AnnotationView</a></li><li><a href="BasCls.html">BasCls</a></li><li><a href="ClassItemValue.html">ClassItemValue</a></li><li><a href="CoordinateConvert.html">CoordinateConvert</a></li><li><a href="CoordinateConvertParameter.html">CoordinateConvertParameter</a></li><li><a href="CrossData.html">CrossData</a></li><li><a href="DataBase.html">DataBase</a></li><li><a href="DataBaseSync.html">DataBaseSync</a></li><li><a href="Document.html">Document</a></li><li><a href="DocumentItem.html">DocumentItem</a></li><li><a href="Dot.html">Dot</a></li><li><a href="Dot3D.html">Dot3D</a></li><li><a href="Dots.html">Dots</a></li><li><a href="Dots3D.html">Dots3D</a></li><li><a href="DownloadDataBaseParmeters.html">DownloadDataBaseParmeters</a></li><li><a href="DownloadLayerOption.html">DownloadLayerOption</a></li><li><a href="ElpParam.html">ElpParam</a></li><li><a href="ElpTransformation.html">ElpTransformation</a></li><li><a href="ElpTransParam.html">ElpTransParam</a></li><li><a href="Environment.html">Environment</a></li><li><a href="ExtField.html">ExtField</a></li><li><a href="FClsInfo.html">FClsInfo</a></li><li><a href="Feature.html">Feature</a></li><li><a href="FeatureEdit.html">FeatureEdit</a></li><li><a href="FeaturePagedResult.html">FeaturePagedResult</a></li><li><a href="FeatureQuery.html">FeatureQuery</a></li><li><a href="FeatureSync.html">FeatureSync</a></li><li><a href="Field.html">Field</a></li><li><a href="Fields.html">Fields</a></li><li><a href="FillStyle.html">FillStyle</a></li><li><a href="GeneralVectorLabel.html">GeneralVectorLabel</a></li><li><a href="GeoAnno.html">GeoAnno</a></li><li><a href="GeoLine.html">GeoLine</a></li><li><a href="GeoLines.html">GeoLines</a></li><li><a href="Geometry.html">Geometry</a></li><li><a href="GeometryExp.html">GeometryExp</a></li><li><a href="GeometryParams.html">GeometryParams</a></li><li><a href="GeomInfo.html">GeomInfo</a></li><li><a href="GeoPoints.html">GeoPoints</a></li><li><a href="GeoPolygon.html">GeoPolygon</a></li><li><a href="GeoPolygons.html">GeoPolygons</a></li><li><a href="GeoVarLine.html">GeoVarLine</a></li><li><a href="Graphic.html">Graphic</a></li><li><a href="GraphicCircle.html">GraphicCircle</a></li><li><a href="GraphicHeatmap.html">GraphicHeatmap</a></li><li><a href="GraphicImage.html">GraphicImage</a></li><li><a href="GraphicMultiPoint.html">GraphicMultiPoint</a></li><li><a href="GraphicPoint.html">GraphicPoint</a></li><li><a href="GraphicPolygon.html">GraphicPolygon</a></li><li><a href="GraphicPolylin.html">GraphicPolylin</a></li><li><a href="GraphicsOverlay.html">GraphicsOverlay</a></li><li><a href="GraphicsOverlays.html">GraphicsOverlays</a></li><li><a href="GraphicStippleLine.html">GraphicStippleLine</a></li><li><a href="GraphicText.html">GraphicText</a></li><li><a href="GroupLayer.html">GroupLayer</a></li><li><a href="HeatmapPoint.html">HeatmapPoint</a></li><li><a href="Image.html">Image</a></li><li><a href="IntUser.html">IntUser</a></li><li><a href="Label.html">Label</a></li><li><a href="LabelInfo.html">LabelInfo</a></li><li><a href="LatLng.html">LatLng</a></li><li><a href="LayerEnum.html">LayerEnum</a></li><li><a href="LinePlaceInfo.html">LinePlaceInfo</a></li><li><a href="LineStyle.html">LineStyle</a></li><li><a href="LinInfo.html">LinInfo</a></li><li><a href="MagnifierOption.html">MagnifierOption</a></li><li><a href="Map.html">Map</a></li><li><a href="MapLayer.html">MapLayer</a></li><li><a href="MapPosition.html">MapPosition</a></li><li><a href="Maps.html">Maps</a></li><li><a href="MapServer.html">MapServer</a></li><li><a href="MapServiceInfo.html">MapServiceInfo</a></li><li><a href="MapServiceLayerInfo.html">MapServiceLayerInfo</a></li><li><a href="MapView.html">MapView</a></li><li><a href="MeasureContentWillChangeListener.html">MeasureContentWillChangeListener</a></li><li><a href="MeasureOption.html">MeasureOption</a></li><li><a href="Model.html">Model</a></li><li><a href="ModelsOverlay.html">ModelsOverlay</a></li><li><a href="MultiClassTheme.html">MultiClassTheme</a></li><li><a href="MultiClassThemeInfo.html">MultiClassThemeInfo</a></li><li><a href="OGCWMTSMapServer.html">OGCWMTSMapServer</a></li><li><a href="PntInfo.html">PntInfo</a></li><li><a href="PointF.html">PointF</a></li><li><a href="PointPlaceInfo.html">PointPlaceInfo</a></li><li><a href="PointStyle.html">PointStyle</a></li><li><a href="QueryBound.html">QueryBound</a></li><li><a href="QueryDef.html">QueryDef</a></li><li><a href="RangeTheme.html">RangeTheme</a></li><li><a href="RangeThemeInfo.html">RangeThemeInfo</a></li><li><a href="Record.html">Record</a></li><li><a href="RecordSet.html">RecordSet</a></li><li><a href="Rect.html">Rect</a></li><li><a href="RegInfo.html">RegInfo</a></li><li><a href="RegionPlaceInfo.html">RegionPlaceInfo</a></li><li><a href="ServerLayer.html">ServerLayer</a></li><li><a href="SFeatureCls.html">SFeatureCls</a></li><li><a href="SimpleLabel.html">SimpleLabel</a></li><li><a href="SimpleModelLayer.html">SimpleModelLayer</a></li><li><a href="SimpleModelLayerUtil.html">SimpleModelLayerUtil</a></li><li><a href="SimpleTheme.html">SimpleTheme</a></li><li><a href="SketchEditor.html">SketchEditor</a></li><li><a href="SketchStyle.html">SketchStyle</a></li><li><a href="SnappingOption.html">SnappingOption</a></li><li><a href="SpaAnalysis.html">SpaAnalysis</a></li><li><a href="SpaCalculator.html">SpaCalculator</a></li><li><a href="SpaProjection.html">SpaProjection</a></li><li><a href="SpaRelation.html">SpaRelation</a></li><li><a href="SRefData.html">SRefData</a></li><li><a href="SyncBase.html">SyncBase</a></li><li><a href="SyncDataBaseParmeters.html">SyncDataBaseParmeters</a></li><li><a href="SyncLayerOption.html">SyncLayerOption</a></li><li><a href="TextAnnInfo.html">TextAnnInfo</a></li><li><a href="TextAnno.html">TextAnno</a></li><li><a href="TextStyle.html">TextStyle</a></li><li><a href="Theme.html">Theme</a></li><li><a href="ThemeInfo.html">ThemeInfo</a></li><li><a href="Themes.html">Themes</a></li><li><a href="TileMapServer.html">TileMapServer</a></li><li><a href="UniqueTheme.html">UniqueTheme</a></li><li><a href="UniqueThemeInfo.html">UniqueThemeInfo</a></li><li><a href="VectorCls.html">VectorCls</a></li><li><a href="VectorLabel.html">VectorLabel</a></li><li><a href="VectorLayer.html">VectorLayer</a></li><li><a href="VectorMapServer.html">VectorMapServer</a></li><li><a href="VectorTheme.html">VectorTheme</a></li><li><a href="VectorTileMapServer.html">VectorTileMapServer</a></li><li><a href="VisualMap.html">VisualMap</a></li><li><a href="XClsInfo.html">XClsInfo</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addAnnotation">addAnnotation</a></li><li><a href="global.html#addAnnotations">addAnnotations</a></li><li><a href="global.html#animatePosition">animatePosition</a></li><li><a href="global.html#distanceOfGeometry">distanceOfGeometry</a></li><li><a href="global.html#getAllAnnotations">getAllAnnotations</a></li><li><a href="global.html#getAnnotation">getAnnotation</a></li><li><a href="global.html#getAnnotationCount">getAnnotationCount</a></li><li><a href="global.html#getGeometryByType">getGeometryByType</a></li><li><a href="global.html#indexOf">indexOf</a></li><li><a href="global.html#initialize">initialize</a></li><li><a href="global.html#moveAnnotation">moveAnnotation</a></li><li><a href="global.html#removeAllAnnotations">removeAllAnnotations</a></li><li><a href="global.html#removeAnnotation">removeAnnotation</a></li><li><a href="global.html#removeAnnotationByIndex">removeAnnotationByIndex</a></li><li><a href="global.html#removeAnnotations">removeAnnotations</a></li><li><a href="global.html#requestAuthorization">requestAuthorization</a></li><li><a href="global.html#setResolution">setResolution</a></li><li><a href="global.html#setScale">setScale</a></li><li><a href="global.html#setSize">setSize</a></li><li><a href="global.html#setSystemLibraryPath">setSystemLibraryPath</a></li><li><a href="global.html#toGeometry">toGeometry</a></li><li><a href="global.html#toGeometrys">toGeometrys</a></li><li><a href="global.html#toGraphicsFromGeometry">toGraphicsFromGeometry</a></li><li><a href="global.html#updatePositionbyViewPoint">updatePositionbyViewPoint</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Fri Jan 17 2020 16:23:46 GMT+0800 (GMT+08:00)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
